home *** CD-ROM | disk | FTP | other *** search
- PAGE ,132
- ;******************************************************************************
- ; SYSREQ - Turns the Sys-Req key on PC-AT's into a pause key.
- ;
- ; Description - SYSREQ loads up an interrupt service routine to service
- ; the interrupt that is generated when the Sys-Req key is
- ; pressed on the PC-AT's keyboard (interrupt 15H). The
- ; first time the key is pressed the routine enters a
- ; pause loop that is only exited when the key is pressed
- ; a second time (i.e. press it once - pause; press it again -
- ; continue). The advantages to SYSREQ are 1) only one key
- ; stroke to pause instead of two (Crtl-Num-Lock), and 2) it
- ; doesn't need to filter all key stokes to determine when
- ; the key is depressed, since the BIOS keyboard service
- ; routine generates the interrupt when Sys-Req is pressed.
- ; The disadvantage is that it only works on AT's.
- ;
- ; Notes - The source code was written for assembly with
- ; Microsoft's Marco-Assembler.
- ;
- ; Date - 17 May 1986
- ;
- ; Author - David Oro
- ;******************************************************************************
- ;=======EQUATES
- CLEAR_F EQU 000H ;Value of cleared flag.
- SET_F EQU 001H ;Value of set flag.
- SYS_REQ_INT EQU 015H ;Interrupt vector for Sys-Req key.
- DOS_FUNCTION EQU 021H ;DOS Function request interrupt.
- DISPLAY_STRING EQU 009H ;DOS Display string function.
- GET_VECTOR EQU 035H ;DOS Get vector address function.
- SET_VECTOR EQU 025H ;DOS Set vector address function.
- TERMINATE_RESIDENT EQU 027H ;DOS Terminate but stay resident int.
- BIOS_DATA EQU 00040H ;Base segment of BIOS data area.
- CRT_MODE EQU 00049H ;Offset of CRT_MODE byte in BIOS data.
- CRT_MODE_SET EQU 00065H ;Offset of CRT_MODE_SET byte.
- CRT_CONTROL EQU 003D8H ;Address of crt control port.
-
- ;=======CODE
- CSEG SEGMENT PARA PUBLIC 'CODE'
- ORG 00100H
- ASSUME CS:CSEG,DS:CSEG
-
- START: JMP SHORT INITIALIZE ;Initialize variables.
-
- OLD_INT LABEL DWORD ;Space for old interrupt vector
- OLD_INT_IP DW ? ; Instruction pointer
- OLD_INT_CS DW ? ; Code segment
- PAUSE_ACTIVE DB CLEAR_F ;Pause active flag
-
- NEW_INT PROC FAR ;Interrupt service routine entry point.
- ASSUME DS:NOTHING
-
- STI ;Turn interrupts back on.
- CMP AX, 08500H ;Is Sys-Req key pushed down?
- JE SYS_REQ_MAKE ; Yes: Service pause request.
- CMP AX, 08501H ;Is Sys-Req key let up?
- JE EXIT_INT ; Yes: Ignore it and exit.
- JMP CS:OLD_INT ;If not Sys-Req key, do old interrupt.
-
- SYS_REQ_MAKE:
- CMP CS:PAUSE_ACTIVE, SET_F ;Is pause currently active?
- JE QUIT_PAUSE ; Yes: Reset pause flag and exit.
- MOV CS:PAUSE_ACTIVE, SET_F ; No: Set pause flag.
- PUSH DS ;Save data segment
- PUSH BX ;Save BX
- MOV AX, BIOS_DATA ;Point to ...
- MOV DS, AX ; ... BIOS data area base.
- MOV BX, CRT_MODE ;Point to current video mode.
- MOV AL, [BX] ;Get current video mode.
- CMP AL, 007H ;Is it monochrome?
- JAE MONO ; Yes: Then don't worry about it
- MOV BX, CRT_MODE_SET ; No: point to video mode setting...
- MOV AL, [BX] ; and get it...
- PUSH DX ; and save DX...
- MOV DX, CRT_CONTROL ; and point to video controller...
- OUT DX, AL ; and turn video on...
- POP DX ; and restore DX.
-
- MONO: POP BX ;Restore BX.
- POP DS ;Restore data segment.
-
- WAIT_LOOP:
- CMP CS:PAUSE_ACTIVE, SET_F ;Is pause flag set?
- JE WAIT_LOOP ; Yes: Loop until it is cleared.
- IRET ; No: Return from interrupt.
-
- QUIT_PAUSE:
- MOV CS:PAUSE_ACTIVE,CLEAR_F ;Clear pause flag.
- EXIT_INT:
- IRET ;Exit interrupt.
-
- NEW_INT ENDP ;End of interrupt service routine.
-
- INITIALIZE:
- ASSUME DS:CSEG
- MOV AL, SYS_REQ_INT
- MOV AH, GET_VECTOR
- INT DOS_FUNCTION ;Get old interrupt vector
- MOV OLD_INT_IP, BX ; save instruction pointer
- MOV OLD_INT_CS, ES ; save code segment
-
-
- MOV DX, OFFSET NEW_INT ;New interrupt instruction pointer
- MOV AL, SYS_REQ_INT
- MOV AH, SET_VECTOR
- INT DOS_FUNCTION ;Set new interrupt address
-
- MOV DX, OFFSET MESSAGE ;Output message...
- MOV AH, DISPLAY_STRING ; to the standard...
- INT DOS_FUNCTION ; output device.
-
- MOV DX, OFFSET INITIALIZE ;End of ISR code
- INT TERMINATE_RESIDENT ;Terminate but leave ISR resident.
-
- MESSAGE DB 00DH,00AH,'Sys-Req key pause routine installed.',00DH,00AH,'$'
-
- CSEG ENDS
- END START